Skip to content

[Phase 4] - Remove module-level reportAttributesDerivedValue in isEmptyReport() - #100693

Merged
luacmartins merged 9 commits into
Expensify:mainfrom
hoangzinh:66427/phase4-isEmptyReport
Sep 18, 2026
Merged

luacmartins merged 9 commits into
Expensify:mainfrom
hoangzinh:66427/phase4-isEmptyReport

Conversation

@hoangzinh

@hoangzinh hoangzinh commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Remove module-level reportAttributesDerivedValue read inside isEmptyReport() by accepting an derivedIsEmptyReport parameter, mirroring Phase 2's derivedReportName pattern.

  • Add reportIsEmptySelector to ReportAttributes selectors
  • Add useDerivedIsEmptyReport hook
  • Thread derivedIsEmptyReport through isUnread, reasonForReportToBeInOptionList, and ShouldReportBeInOptionListParams
  • Update call sites in SidebarUtils, OptionsListUtils, DebugUtils, MarkAllMessageAsRead, and components/hooks
  • Add tests for new hook

Fixed Issues

$ #66427
PROPOSAL:

Tests

  • Verify that no errors appear in the JS console

Offline tests

QA Steps

// TODO: These must be filled out, or the issue title must include "[No QA]."

1. LHN displays reports correctly

  1. Check chat list in LHN
  2. Verify empty chats do NOT appear
  3. Verify non-empty unread chats show bold text
  4. Verify pinned empty chats still appear

2. Inbox Unread tab and Mark all as read

  1. Go to Inbox, switch to Unread tab
  2. Verify only reports with unread messages appear
  3. Verify empty reports do NOT appear in Unread tab
  4. Long-press on Unread tab, select "Mark all as read"
  5. Verify all unread indicators are cleared and Unread tab count goes to 0

3. Report View — Chat navigates to unread position

  1. Have another user send multiple messages in a chat
  2. Open that unread chat
  3. Verify chat scrolls to correct unread position
  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Screen.Recording.2026-09-06.195109.mp4

@hoangzinh
hoangzinh force-pushed the 66427/phase4-isEmptyReport branch from e458a69 to fbb6dab Compare September 9, 2026 16:20
Remove module-level reportAttributesDerivedValue read inside
isEmptyReport() by accepting an optional derivedIsEmptyReport
parameter, mirroring Phase 2's derivedReportName pattern.

- Add reportIsEmptySelector to ReportAttributes selectors
- Add useDerivedIsEmptyReport hook
- Thread derivedIsEmptyReport through isUnread,
  reasonForReportToBeInOptionList, and ShouldReportBeInOptionListParams
- Update call sites in SidebarUtils, OptionsListUtils, DebugUtils,
  MarkAllMessageAsRead, and components/hooks
- Add tests for isEmptyReport cache hit/miss and new hook

Part of Expensify#66427 (Phase 4)
@hoangzinh
hoangzinh force-pushed the 66427/phase4-isEmptyReport branch from fbb6dab to a39db3c Compare September 9, 2026 16:26
@codecov

codecov Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
src/hooks/useMarkAsRead.ts 96.11% <100.00%> (+0.03%) ⬆️
src/hooks/useReportActionsListModel.ts 100.00% <100.00%> (ø)
src/hooks/useReportAttributes.ts 81.25% <100.00%> (+4.32%) ⬆️
src/libs/DebugUtils.ts 69.06% <ø> (ø)
src/libs/OptionsListUtils/index.ts 91.32% <100.00%> (+<0.01%) ⬆️
src/libs/ReportUtils.ts 87.30% <100.00%> (-0.02%) ⬇️
src/libs/SidebarUtils.ts 90.96% <100.00%> (+0.08%) ⬆️
src/libs/UnreadIndicatorUpdater/index.ts 92.98% <100.00%> (+0.52%) ⬆️
src/libs/actions/Report/MarkAllMessageAsRead.tsx 90.62% <100.00%> (ø)
...report/ContextMenu/BaseReportActionContextMenu.tsx 87.73% <100.00%> (+0.07%) ⬆️
... and 5 more
... and 32 files with indirect coverage changes

# Conflicts:
#	src/libs/actions/Report/MarkAllMessageAsRead.tsx
#	src/pages/inbox/sidebar/InboxTabSelector.tsx
@hoangzinh
hoangzinh force-pushed the 66427/phase4-isEmptyReport branch 2 times, most recently from f809945 to de2c474 Compare September 10, 2026 06:03
@hoangzinh
hoangzinh force-pushed the 66427/phase4-isEmptyReport branch from de2c474 to 3c74c72 Compare September 10, 2026 06:13
- Connect to DERIVED.REPORT_ATTRIBUTES Onyx key
- Pass derivedIsEmptyReport to isUnread and shouldReportBeInOptionList
@hoangzinh
hoangzinh force-pushed the 66427/phase4-isEmptyReport branch from d68996c to 1981a18 Compare September 11, 2026 07:11
@hoangzinh
hoangzinh marked this pull request as ready for review September 11, 2026 10:43
@hoangzinh
hoangzinh requested review from a team as code owners September 11, 2026 10:43
@melvin-bot
melvin-bot Bot requested review from DylanDylann and joekaufmanexpensify and removed request for a team September 11, 2026 10:43
@melvin-bot

melvin-bot Bot commented Sep 11, 2026

Copy link
Copy Markdown

@DylanDylann Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot
melvin-bot Bot removed the request for review from a team September 11, 2026 10:43
@github-actions

Copy link
Copy Markdown
Contributor

This PR adds a new Onyx.connectWithoutView call, so I've requested a review from the Onyx performance reviewers (@tgolen, @mountiny, @luacmartins) — a review from any one of them is enough. Please add a link in your PR description to the Slack discussion where the @frontend-performance team approved using connectWithoutView here.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1981a189a8

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@joekaufmanexpensify

Copy link
Copy Markdown
Contributor

No product review needed.

@joekaufmanexpensify
joekaufmanexpensify removed their request for review September 11, 2026 14:26
Comment on lines +68 to +69
let reportAttributesDerived: ReportAttributesDerivedValue['reports'] | undefined;
Onyx.connectWithoutView({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please leave a clear comment why its fine to use it here? thanks

@hoangzinh hoangzinh Sep 12, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I done in a24baed and added comment explaining this subscription updates the unread indicator count, which is not linked to UI and doesn't update any UI state

@hoangzinh

Copy link
Copy Markdown
Contributor Author

This PR adds a new Onyx.connectWithoutView call, so I've requested a review from the Onyx performance reviewers (@tgolen, @mountiny, @luacmartins) — a review from any one of them is enough. Please add a link in your PR description to the Slack discussion where the @frontend-performance team approved using connectWithoutView here.

Slack discussion here https://expensify.slack.com/archives/C08CZDJFJ77/p1789124171552799

@tgolen
tgolen removed their request for review September 17, 2026 14:37
@luacmartins
luacmartins removed their request for review September 17, 2026 19:58
@mountiny

Copy link
Copy Markdown
Contributor

And more

@github-actions

Copy link
Copy Markdown
Contributor

This PR adds a new Onyx.connectWithoutView call, so I've requested a review from the Onyx performance reviewers (@tgolen, @mountiny, @luacmartins, @chuckdries) — a review from any one of them is enough. Please add a link in your PR description to the Slack discussion where the @frontend-performance team approved using connectWithoutView here.

@github-actions
github-actions Bot requested a review from tgolen September 18, 2026 01:23
triggerUnreadUpdate();
});

export default {getUnreadReportsForUnreadIndicator};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hoangzinh Could we remove this export (it's not used anywhere) to prevent someone from reusing this function elsewhere?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's used in tests/unit/UnreadIndicatorUpdaterTest.ts I guess we should leave it as it is

@DylanDylann

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Screen.Recording.2026-09-18.at.11.44.27.mov

@DylanDylann

DylanDylann commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

One NIT and failed ESLint check

Variable was connected to Onyx but never read — isEmptyReport
receives derivedIsEmptyReport as a parameter instead.
@hoangzinh

Copy link
Copy Markdown
Contributor Author

One NIT and failed ESLint check

I fixed the failing ESLint checks

@melvin-bot
melvin-bot Bot requested a review from marcochavezf September 18, 2026 08:36

@mountiny mountiny left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approving the connectWithoutView usage

@tgolen
tgolen removed their request for review September 18, 2026 14:27
@luacmartins
luacmartins merged commit 50e6408 into Expensify:main Sep 18, 2026
37 of 39 checks passed
@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions

Copy link
Copy Markdown
Contributor

🚧 luacmartins has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/luacmartins in version: 9.4.90-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 No help site changes are required — no draft PR was created.

This PR is an internal refactor with no user-facing behavior change, so nothing under App/docs/articles needs updating.

Why I concluded no docs are needed

What changed: [Phase 4] removes the module-level reportAttributesDerivedValue read inside isEmptyReport() and threads the value in as a derivedIsEmptyReport parameter instead. The diff adds reportIsEmptySelector, adds the useDerivedIsEmptyReport hook, and updates call sites in SidebarUtils, OptionsListUtils, DebugUtils, MarkAllMessageAsRead, and related components.

Checks I ran against the diff (21 files):

Check Result
Changes to src/languages/*.ts None
New or reworded user-facing copy (labels, buttons, tab names, errors) None — the only new strings are Jest it(...) test descriptions
New or removed features, settings, or menu items None
Changes to a documented workflow or navigation path None
Changes to existing docs/ files None

Linked issue: Remove Onyx.connect() for the key: ONYXKEYS.DERIVED.REPORT_ATTRIBUTES in src/libs/ReportUtils.ts — labelled Engineering / Improvement, confirming this is a code-architecture cleanup rather than a product change.

The QA steps (LHN empty-chat filtering, the Unread tab, Mark all as read) all verify that existing behavior is preserved. Preserved behavior means the existing help articles are still accurate, so there is nothing to rewrite.


One note on the sign-off you asked for: since no docs changes were required, there is no help site PR to link or mark Ready for review. If you'd still like an article refreshed for another reason, reply with @MelvinBot and the article you have in mind and I'll draft it.

@hoangzinh, please confirm that this PR is a behavior-preserving refactor. If any user-facing behavior did change, let me know what it is and I'll create the help site draft PR.


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/lakchote in version: 9.4.90-2 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants